
import com.etop.weibo.beans.User;
import com.etop.weibo.dao.UserDao;
import com.etop.weibo.service.UserService;
import com.etop.weibo.util.DaoProperties;
import com.etop.weibo.util.WeiBoException;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;

/**
 *
 * @author jansing
 */
public class Common {
    @Test    
    public void testProperties(){
        UserDao ud = (UserDao) DaoProperties.getDao("UserDao");
        User u = new User();
        u.setUsername("ggg");
        u.setPassword("hhh");
        u.setNickname("jjj");
        ud.add(u);
    }
    
    
    public void testValueof(){
        try{
            throw new WeiBoException("");
//        int a = Integer.valueOf("123.231"); //error : NumberFormatException
//        System.out.println(a);
        }catch(Exception e){
            System.out.println(e.getClass()+ e.getMessage());
        }
    }
    
    public void testThrow(){
        try{
            throw1();
        }catch(WeiBoException e){
            System.out.println(e);
        }
    }
    
    public void throw1(){
        System.out.println("1");
        throw2();
        System.out.println("2");
    }
    public void throw2(){
        throw new com.etop.weibo.util.WeiBoException("ok?");
    }
    
    public void TestList(){
        List<Integer> list = new ArrayList<Integer>();
        System.out.println(list.size());
    }
    
    
    public void TestRedirect(){
        String path = "redirect:/user?method=login";
        String redirectPrefix = "redirect:";
        System.out.println(path);
        System.out.println(redirectPrefix.length());
        System.out.println(path.length());
        System.out.println(path.substring(redirectPrefix.length(), path.length()));
    }

}
